﻿

using NServiceBus.Management.Managers;
using NServiceBus.Management.Messages.Tracking;

namespace NServiceBus.Management.MessageHandlers
{
    public class TrackingMessageHandler : BaseMessageHandler<EnableTrackingCommand>,
                                          IMessageHandler<ReplayTrackedMessage>
    {
        public ITrackingManager TrackingManager{ get; set;}

        public override void Handle(EnableTrackingCommand command)
        {
            TrackingManager.EnableTrackingFor(command);
        }

        public void Handle(ReplayTrackedMessage message)
        {
            message.TrackedMessage.CopyMessagesToBody();
            Bus.Send(message.TrackedMessage.Body);
        }
    }
}
